package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.UpdateHeadBean;
import com.lwj.liwanjia.impl.UpdateHeadView;
import com.lwj.liwanjia.model.UpdateHeadModel;

import java.io.File;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/13.
 */

public class UpdateHeadPresenter {
    private UpdateHeadModel updateHeadModel;
    private UpdateHeadView updateHeadView;

    public UpdateHeadPresenter(UpdateHeadView updateHeadView) {
        this.updateHeadView = updateHeadView;
        updateHeadModel = new UpdateHeadModel();
    }

    public void updateHead(String token, File file) {
        if (updateHeadView != null) {
            updateHeadModel.updateHead(token, new Subscriber<UpdateHeadBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    updateHeadView.showError((Exception) e);
                }

                @Override
                public void onNext(UpdateHeadBean updateHeadBean) {
                    updateHeadView.updateHead(updateHeadBean);
                }
            }, file);
        }
    }
}
